#include <stdio.h>
#include <ctype.h>

double atof(char s[]);

int main()
{
    double out1, out2, out3;
    char cnum1[] = "12.34e+3";
    char cnum2[] = "12.34E-3";
    char cnum3[] = "12.3456e+3";
    out1 = atof(cnum1);
    out2 = atof(cnum2);
    out3 = atof(cnum3);

    printf("input1 = %s\n  out1 = %f\n", cnum1, out1);
    printf("input2 = %s\n  out2 = %f\n", cnum2, out2);
    printf("input3 = %s\n  out3 = %f\n", cnum3, out3);

    return 0;
}

double atof(char s[])
{
    double val, val2, power, ret;
    int i, sign, flag, j, power2;

    for (i = 0; isspace(s[i]); i++)
        ;
    sign = (s[i] == '-') ? -1 : 1;
    if (s[i] == '+' || s[i] == '-')
        i++;
    for (val = 0.0; isdigit(s[i]); i++)
        val = 10.0 * val + (s[i] - '0');
    if (s[i] == '.')
        i++;
    for (power = 1.0; isdigit(s[i]); i++)
    {
        val = val * 10.0 + (s[i] - '0');
        power *= 10.0;
    }
    if (s[i] == 'e' || s[i] == 'E')
        i++;
    if (s[i] == '+')
        flag = 1;
    else
        flag = 0;
    i++;
    for (power2 = 0; isdigit(s[i]); i++)
    {
        power2 = power2 * 10 + (s[i] - '0');
    }
    for (j = 0, val2 = 1.0; j < power2; j++)
        val2 = val2 * 10.0;

    if (flag)
        ret = sign * val * val2 / power;
    else
        ret = sign * val / power / val2;

    return ret;
}